#include "PhoneToSetInfraredCmd.h"

OPInfraredToLearnCmd::OPInfraredToLearnCmd(QObject *parent)
    : BaseCmd(parent)
{
    this->m_protocolType = ProtocolType::CloudProtocol;
    this->m_functionCode = FunctionCode;
}

Package OPInfraredToLearnCmd::toPackage()
{
    Package package;
    return package;
}

void OPInfraredToLearnCmd::unPackage(Package package)
{
    m_nwk=package.body().mid(0,2).toHex().toUpper();
    m_addr=package.body().mid(2,2).toHex().toInt(0,16);
}



/*----------------------------------------------------------------------------*/



TestInfraredToLearnCmd::TestInfraredToLearnCmd(QObject *parent)
    : BaseCmd(parent)
{
    this->m_protocolType = ProtocolType::CloudProtocol;
    this->m_functionCode = FunctionCode;
}

Package TestInfraredToLearnCmd::toPackage()
{
    Package package;
    return package;
}

void TestInfraredToLearnCmd::unPackage(Package package)
{
    m_nwk=package.body().mid(0,2).toHex().toUpper();
    m_addr=package.body().mid(2,2).toHex().toInt(0,16);
}



/*----------------------------------------------------------------------------*/



SaveInfraredToLearnCmd::SaveInfraredToLearnCmd(QObject *parent)
    : BaseCmd(parent)
{
    this->m_protocolType = ProtocolType::CloudProtocol;
    this->m_functionCode = FunctionCode;
}

Package SaveInfraredToLearnCmd::toPackage()
{
    Package package;
    return package;
}

void SaveInfraredToLearnCmd::unPackage(Package package)
{

    quint8 namelength=package.body().mid(4,2).toHex().toInt(0,16);
    QString Name = QString::fromUtf8(package.body().mid(6,namelength));
    m_nwk=package.body().mid(0,2).toHex().toUpper();
    m_Value=package.body().mid(2,2).toHex().toInt(0,16);
    m_Name=Name;
}
